-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add links and events to tracing payload #21
Conversation
The PR looks good. However, it would be great to have some more capabilities regarding links
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Nice addition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR. I suggested a couple of changes to make the new functionality more consistent with the existing behavior
examples/template/template.js
Outdated
{service: "shop-backend", attributes: {"http.status_code": 403}}, | ||
{service: "shop-backend", name: "authenticate", attributes: {"http.request.header.accept": ["application/json"]}}, | ||
{service: "auth-service", name: "authenticate", attributes: {"http.status_code": 403}}, | ||
{service: "test-random", name: "events", randomEvents: {exceptionCount: 1, count: 2, randomAttributes: {count: 5, cardinality: 2}}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this template the span and service names etc. mimic traces from a somewhat plausible e-commerce service landscape. It would be good to keep this and choose less generic service (test-random) and span names (links, events) here
pkg/tracegen/templated.go
Outdated
RandomAttributes *AttributeParams `js:"randomAttributes"` | ||
} | ||
|
||
type LinkDefaults struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For randomly generated attributes the struct is called AttributeParams
and it is used in SpanTemplate
and SpanDefaults
. Do you think we can do the same for links i.e. merge LinkDefaults
and RandomLinks
to LinkParams
? If you use Rate
instead of Count
it should be possible to merge LinkDefaults
and RandomLinks
into one struct without losing functionality.
The main advantage beside consistency is that users don't have to remember two similar sets of parameters and where to use which one.
pkg/tracegen/templated.go
Outdated
type LinkDefaults struct { | ||
// LinkToPreviousSpanIndex true will set TraceID and SpanID the same as the previous span | ||
// Unless it is the first span then a random TraceID and a random SpanID will be used | ||
LinkToPreviousSpanIndex bool `js:"linkToPreviousSpanIndex"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we could make true
the default for all links and remove this option. The reason is that this option is very specific and does not leave much room for future changes in the linking behavior without making this option obsolete. Maybe we want to link across traces in the future or link to random siblings in the same trace ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. will just make it link to the previous span as the default until we can support linking to specific trace/span in the future
pkg/tracegen/templated.go
Outdated
RandomAttributes *AttributeParams `js:"randomAttributes"` | ||
} | ||
|
||
type EventDefaults struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as for links about merging EventDefaults
and RandomEvents
to EventParams
pkg/tracegen/templated.go
Outdated
RandomAttributes: defaults.EventDefaults.RandomAttributes, | ||
Count: int(eventDefaultsRate), | ||
} | ||
} else if idx%int(1/eventDefaultsRate) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use a random factor instead of the index to decide whether to add an event. The condition could look like this: random.Float() < eventDefaultsRate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
pkg/tracegen/templated.go
Outdated
RandomAttributes: defaults.LinkDefaults.RandomAttributes, | ||
Count: int(linkDefaultsRate), | ||
} | ||
} else if idx%int(1/linkDefaultsRate) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment as for events: consider using a random factor instead of the index
pkg/tracegen/templated.go
Outdated
// Random events generated for each span | ||
EventDefaults EventDefaults `js:"eventDefaults"` | ||
// Random links generated for each span | ||
LinkDefaults LinkDefaults `js:"linkDefaults"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to RandomEvents
and RandomLinks
in order to be more consistent with the existing RandomAttributes
examples/template/template.js
Outdated
randomAttributes: {count: 2, cardinality: 5} | ||
randomAttributes: {count: 2, cardinality: 5}, | ||
eventDefaults: {generateExceptionOnError: true, count: 1.0, randomAttributes: {count: 2, cardinality: 3}}, | ||
linkDefaults: {linkToPreviousSpanIndex: true, count: 1.0, randomAttributes: {count: 2, cardinality: 3}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this was not adjusted to the latest changes
pkg/tracegen/templated.go
Outdated
EventDefaults EventParams `js:"eventDefaults"` | ||
// Random links generated for each span | ||
LinkDefaults LinkParams `js:"linkDefaults"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename to RandomEvents
and RandomLinks
in order to be consistent with RandomAttributes
and field names in SpanTemplate
examples/template/template.js
Outdated
{service: "shop-backend", name: "authenticate", attributes: {"http.request.header.accept": ["application/json"]}}, | ||
{service: "auth-service", name: "authenticate", attributes: {"http.status_code": 403}}, | ||
{service: "cart-service", name: "checkout", randomEvents: {exceptionCount: 1, count: 2, randomAttributes: {count: 5, cardinality: 2}}}, | ||
{service: "billing-service", name: "payment", randomLinks: {linkToPreviousSpanIndex: true, count: 2, randomAttributes: {count: 3, cardinality: 2}}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also not updated to the latest changes
examples/template/template.js
Outdated
{service: "shop-backend", attributes: {"http.status_code": 403}}, | ||
{service: "shop-backend", name: "authenticate", attributes: {"http.request.header.accept": ["application/json"]}}, | ||
{service: "auth-service", name: "authenticate", attributes: {"http.status_code": 403}}, | ||
{service: "cart-service", name: "checkout", randomEvents: {exceptionCount: 1, count: 2, randomAttributes: {count: 5, cardinality: 2}}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I test this together with the changes in PR grafana/tempo#3163 the events look a bit odd.
- The timestamp is a negative value. In the trace data returned by tempo the timestamp is zero.
- Instead of an event
name
with the value"exception"
there is a fieldmessage
with the value{"Type": "STRING", "Value": "exception"}
TBH I'm not sure about the origin of those problems. Maybe there is also a front-end issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed my latest changes:
|
test outputs against tempo 3163
added "event attribute" in commit to verify changes took place during testing
trace json from querying trace by id